package com.sthz.facepay.mapper;

import static org.apache.ibatis.jdbc.SqlBuilder.BEGIN;
import static org.apache.ibatis.jdbc.SqlBuilder.INSERT_INTO;
import static org.apache.ibatis.jdbc.SqlBuilder.SET;
import static org.apache.ibatis.jdbc.SqlBuilder.SQL;
import static org.apache.ibatis.jdbc.SqlBuilder.UPDATE;
import static org.apache.ibatis.jdbc.SqlBuilder.VALUES;
import static org.apache.ibatis.jdbc.SqlBuilder.WHERE;

import com.sthz.facepay.model.Cash;

public class CashSqlProvider {

    public String insertSelective(Cash record) {
        BEGIN();
        INSERT_INTO("st_cash");
        
        if (record.getId() != null) {
            VALUES("id", "#{id,jdbcType=INTEGER}");
        }
        
        if (record.getAid() != null) {
            VALUES("aid", "#{aid,jdbcType=INTEGER}");
        }
        
        if (record.getCash_money() != null) {
            VALUES("cash_money", "#{cash_money,jdbcType=DOUBLE}");
        }
        
        if (record.getCash_time() != null) {
            VALUES("cash_time", "#{cash_time,jdbcType=TIMESTAMP}");
        }
        
        if (record.getState() != null) {
            VALUES("state", "#{state,jdbcType=TINYINT}");
        }
        
        if (record.getReviewer() != null) {
            VALUES("reviewer", "#{reviewer,jdbcType=VARCHAR}");
        }
        
        if (record.getReason() != null) {
            VALUES("reason", "#{reason,jdbcType=VARCHAR}");
        }
        
        return SQL();
    }

    public String updateByPrimaryKeySelective(Cash record) {
        BEGIN();
        UPDATE("st_cash");
        
        if (record.getAid() != null) {
            SET("aid = #{aid,jdbcType=INTEGER}");
        }
        
        if (record.getCash_money() != null) {
            SET("cash_money = #{cash_money,jdbcType=DOUBLE}");
        }
        
        if (record.getCash_time() != null) {
            SET("cash_time = #{cash_time,jdbcType=TIMESTAMP}");
        }
        
        if (record.getState() != null) {
            SET("state = #{state,jdbcType=TINYINT}");
        }
        
        if (record.getReviewer() != null) {
            SET("reviewer = #{reviewer,jdbcType=VARCHAR}");
        }
        
        if (record.getReason() != null) {
            SET("reason = #{reason,jdbcType=VARCHAR}");
        }
        
        WHERE("id = #{id,jdbcType=INTEGER}");
        
        return SQL();
    }
}